import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BcategoryVO, BcategoryForm, BcategoryQuery } from '@/api/blog/bcategory/types';

/**
 * 查询博客分类列表
 * @param query
 * @returns {*}
 */

export const listBcategory = (query?: BcategoryQuery): AxiosPromise<BcategoryVO[]> => {
  return request({
    url: '/blog/bcategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询博客分类详细
 * @param categoryId
 */
export const getBcategory = (categoryId: string | number): AxiosPromise<BcategoryVO> => {
  return request({
    url: '/blog/bcategory/' + categoryId,
    method: 'get'
  });
};

/**
 * 新增博客分类
 * @param data
 */
export const addBcategory = (data: BcategoryForm) => {
  return request({
    url: '/blog/bcategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改博客分类
 * @param data
 */
export const updateBcategory = (data: BcategoryForm) => {
  return request({
    url: '/blog/bcategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除博客分类
 * @param categoryId
 */
export const delBcategory = (categoryId: string | number | Array<string | number>) => {
  return request({
    url: '/blog/bcategory/' + categoryId,
    method: 'delete'
  });
};
